<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>我的工具</title>
    <!-- Bootstrap -->
    <link href="<?php echo base_url('application/views/bootstrap/css/bootstrap.min.css') ?>" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
    .panel-body {
        height: 300px;
    }
    #content {
        height: 100%;
        font-size: 14px;
        line-height: 1.5;
    }
    </style>
</head>
<body>
    <!-- 全局导航条开始 -->
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">我的工具</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="<?php echo site_url('welcome/index/')?>">PHP网站开发作业提交 </a></li>
                    <li class="active"><a href="<?php echo site_url('tool/index/')?>">在线翻译</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Link</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Action</a></li>
                            <li><a href="#">Another action</a></li>
                            <li><a href="#">Something else here</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">Separated link</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
    <!-- 全局导航条结束 -->
    <!-- 翻译窗口开始 -->
    <div class="container">
        <div class="row">
            <div class="col-md-6">
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h3 class="panel-title">请输入需要翻译的内容：</h3>
                    </div>
                    <div class="panel-body">
                        <div id="content" class="form-control" contenteditable="true" oninput="getTranslate()">这边的内容
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="panel panel-success">
                    <div class="panel-heading">
                        <h3 class="panel-title">翻译结果：</h3>
                    </div>
                    <div class="panel-body">
                        <div id="result">翻译结果显示在这里
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 翻译窗口结束 -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="<?php echo base_url('application/views/bootstrap/js/bootstrap.min.js'); ?>"></script>
    <script>
    function getTranslate() {
        $content = $('#content').text();
        // 修改右侧内容
        // $('#result').html('这是来自jQuery脚本的内容');
        // $('#result').html($content);
        $.ajax({
                method: "POST",
                url: "<?php echo site_url('tool/getData');?>",
                data: { content: $content }
            })
            .done(function(msg) {
                $('#result').html(msg);
            });
    }
    </script>
</body>
</html>